package com.ruoyi.cmemetal.service.impl;

import java.util.List;

import com.ruoyi.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.cmemetal.mapper.ZxWireCutMapper;
import com.ruoyi.cmemetal.domain.ZxWireCut;
import com.ruoyi.cmemetal.service.IZxWireCutService;

/**
 * wirecutService业务层处理
 *
 * @author zhangxu
 * @date 2022-01-01
 */
@Service
public class ZxWireCutServiceImpl implements IZxWireCutService
{
    @Autowired
    private ZxWireCutMapper zxWireCutMapper;

    /**
     * 查询wirecut
     *
     * @param id wirecut主键
     * @return wirecut
     */
    @Override
    public ZxWireCut selectZxWireCutById(Long id)
    {
        return zxWireCutMapper.selectZxWireCutById(id);
    }

    /**
     * 查询wirecut列表
     *
     * @param zxWireCut wirecut
     * @return wirecut
     */
    @Override
    public List<ZxWireCut> selectZxWireCutList(ZxWireCut zxWireCut)
    {
        return zxWireCutMapper.selectZxWireCutList(zxWireCut);
    }

    /**
     * 新增wirecut
     *
     * @param zxWireCut wirecut
     * @return 结果
     */
    @Override
    public int insertZxWireCut(ZxWireCut zxWireCut)
    {
        return zxWireCutMapper.insertZxWireCut(zxWireCut);
    }

    /**
     * 修改wirecut
     *
     * @param zxWireCut wirecut
     * @return 结果
     */
    @Override
    public int updateZxWireCut(ZxWireCut zxWireCut)
    {

        //修改线切割时长
        if(zxWireCut.getOverTime() != null && zxWireCut.getStartTime() != null){
            long time = DateUtils.zxgetDatePoor(zxWireCut.getOverTime(), zxWireCut.getStartTime());
            zxWireCut.setWireCutTime(time);
        }


        return zxWireCutMapper.updateZxWireCut(zxWireCut);
    }

    /**
     * 批量删除wirecut
     *
     * @param ids 需要删除的wirecut主键
     * @return 结果
     */
    @Override
    public int deleteZxWireCutByIds(Long[] ids)
    {
        return zxWireCutMapper.deleteZxWireCutByIds(ids);
    }

    /**
     * 删除wirecut信息
     *
     * @param id wirecut主键
     * @return 结果
     */
    @Override
    public int deleteZxWireCutById(Long id)
    {
        return zxWireCutMapper.deleteZxWireCutById(id);
    }
}
